#include "port.h"

void nixie_tube_choose(uint8_t index, uint8_t number)
{
	//0---F
	uint8_t nixie_tube_table[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

	if(index > 8 || index == 0)
	{
		return;
	}

	if(number > 0xF)
	{
		return;
	}

	switch(index-1)//位选
	{
		case 0: LSC=1;LSB=1;LSA=1;break;
		case 1: LSC=1;LSB=1;LSA=0;break;
		case 2: LSC=1;LSB=0;LSA=1;break;
		case 3: LSC=1;LSB=0;LSA=0;break;
		case 4: LSC=0;LSB=1;LSA=1;break;
		case 5: LSC=0;LSB=1;LSA=0;break;
		case 6: LSC=0;LSB=0;LSA=1;break;
		case 7: LSC=0;LSB=0;LSA=0;break;
		default:return;
	}
	NixieTube=nixie_tube_table[number];//传送段选数据
	delay_ms(10);//延时一段时间，等待显示稳定
	//NixieTube=0x00;//消音


}
void nixie_tube_ctrl(void)
{
	uint8_t i = 0;
	//0---F
	uint8_t nixie_tube_table[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
	NixieTube = nixie_tube_table[0];
	
	for(i=0;i<8;i++)
	{
		switch(i)//位选
		{
			case 0: LSC=1;LSB=1;LSA=1;break;
			case 1: LSC=1;LSB=1;LSA=0;break;
			case 2: LSC=1;LSB=0;LSA=1;break;
			case 3: LSC=1;LSB=0;LSA=0;break;
			case 4: LSC=0;LSB=1;LSA=1;break;
			case 5: LSC=0;LSB=1;LSA=0;break;
			case 6: LSC=0;LSB=0;LSA=1;break;
			case 7: LSC=0;LSB=0;LSA=0;break;
		}
		NixieTube=nixie_tube_table[i];//传送段选数据
		// delay_ms(500);//延时一段时间，等待显示稳定
		delay_ms(1);//延时一段时间，等待显示稳定
		NixieTube=0x00;//消音
	}	
}